<?php

if(isset($_POST['titre'])){
	$titre=$_POST['titre'];
}
else
	$titre='';
	
if(isset($_POST['nom'])){
	$nom=$_POST['nom'];
}
else
	$nom='';
	
if(isset($_POST['prenom'])){
	$prenom=$_POST['prenom'];
}
else
	$prenom='';
	
if(isset($_POST['initiale'])){
	$initiale=$_POST['initiale'];
}
else 
	$initiale='';

if(isset($_POST['genre'])){
	$genre=$_POST['genre'];
}
else 
	$genre='';
	
if(isset($_POST['email'])){
	$email=$_POST['email'];
}
else $email='';

if(isset($_POST['type_ins'])){
	$type_ins=$_POST['type_ins'];
}
else
	$type_ins='';

if(isset($_POST['institution'])){
	$institution=$_POST['institution'];
}
else
	$institution='';

if(isset($_POST['type_instit'])){
	$type_instit=$_POST['type_instit'];
}
else
	$type_instit='';

if(isset($_POST['laboratoire'])){
	$laboratoire=$_POST['laboratoire'];
}
else 
	$laboratoire='';
	
if(isset($_POST['statut'])){
	$statut=$_POST['statut'];
}
else
	$statut;
	
if(isset($_POST['adresse'])){
	$adresse=$_POST['adresse'];
}
else
	$adresse='';
if(isset($_POST['ville'])){
	$ville=$_POST['ville'];
}
else 
	$ville='';
	
if(isset($_POST['zip'])){
	$zip=$_POST['zip'];
}
else
	$zip='';
if(isset($_POST['etat'])){
	$etat=$_POST['etat'];
}
else
	$etat='';
if(isset($_POST['pays'])){
$pays=$_POST['pays'];
}else $pays='';
if(isset($_POST['tel'])){
$tel=$_POST['tel'];
}else $tel='';
if(isset($_POST['mobile'])){
$mobile=$_POST['mobile'];
}else $mobile='';
if(isset($_POST['nationalite'])){
$nationalite=str_replace('|', '', $_POST['nationalite']);
}else $nationalite='';
if(isset($_POST['alimentation'])){
$alimentation=$_POST['alimentation'];
}else $alimentation='';
if(isset($_POST['gluten']) || isset($_POST['lactose'])){
$intolerance='';
if(isset($_POST['gluten'])) $intolerance.=$_POST['gluten'].',';
if(isset($_POST['lactosse'])) $intolerance.=$_POST['lactose'].',';

		
$intolerance=substr($intolerance,0,-1);
}else $intolerance='';
if(isset($_POST['nb_resume'])){
$nb_resume=$_POST['nb_resume'];
}else $nb_resume='';

try{


$request = $connexion->prepare('INSERT INTO users(
	titre, 
	nom, 
	prenom, 
	initial,
	genre,
	email,
	type_ins,
	institution,
	type_instit,
	laboratoire,
	statut,
	adresse,
	ville,
	zip,
	etat,
	pays,
	tel,
	mobile,
	nationalite,
	alimentation,
	intolerance,
	nb_resume
) VALUES (
	?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
)');

$request->execute(array(
	$titre,
	$nom,
	$prenom,
	$initiale,
	$genre,
	$email,
	$type_ins,
	$institution,
	$type_instit,
	$laboratoire,
	$statut,
	$adresse,
	$ville,
	$zip,
	$etat,
	$pays,
	$tel,
	$mobile,
	$nationalite,
	$alimentation,
	$intolerance,
	$nb_resume
));
}
catch($e)
{
	echo $e->getError();	
}
?>